/**
 * Created by Administrator on 2017/7/25.
 */
$(function () {

    //    index country select
    function formatState (state) {
        if (!state.id) { return state.text; }
        /*var scr = "Images/" + state.element.value + ".png";*/
        var $state = $(
            '<span class="flag-div"><img src="' + state.element.getAttribute("data-url") + '" class="img-flag" /> ' + '</span><span>' + state.text + '</span>'
        );
        return $state;
    }
    $(".js-example-templating").select2({
        templateResult: formatState,
        templateSelection: formatState
    }).change(function () {
        $(".select2-selection__rendered span:last-child").html("");
    });
    $(".select2").width('45%').click(function () {
        $(".select2-results__options").niceScroll({cursorcolor: "#333",cursoropacitymin: 0.5});
    });
    $(".select2-selection__rendered span:last-child").html("");
});